import React from 'react';
import { connect } from 'react-redux';
import SubHeaderComponent from '../../../components/subHeader';
import { authLogin } from '../../../assets/js/utils';
import config from '../../../assets/js/conf/config';
import * as Request from '../../../services/home/goods';
import Css from '../../../assets/css/home/balance/end.css';

class End extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            ordernum: ''
        }
        authLogin(props); //会员登录认证
    }

    componentDidMount(){
        this.getOrderNum();
    }

    //获取订单编号
    getOrderNum(){
        const { uid } = this.props.user;
        Request.getOrderNum({ uid }).then(res => {
            if(res.code === 200){
                this.setState({ ordernum: res.data.ordernum });
            }
        });
    }

    render(){
        const { ordernum } = this.state;
        return (
            <div className={Css['page']}>
                <SubHeaderComponent title="订单结束"></SubHeaderComponent>
                <div className={Css['main']}>
                    <div className={Css['list']+' '+Css['success']}>订购成功</div>
                    <div className={Css['list']+' '+Css['ordernum']}>订单编号：{ordernum}</div>
                    <div className={Css['list']}>查看订单</div>
                    <div className={Css['pay-btn']}>去付款</div>
                </div>
            </div>
        )
    }
}

export default connect((store) => {
    return store;
})(End);